<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/layouts/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>文章</title>
    <%@include file="/WEB-INF/layouts/index-header.jsp" %>
    <script src="http://at.alicdn.com/t/font_477528_yc8evnl8dci35wmi.js"></script>
    <style type="text/css">
        .icon {
            width: 1em;
            height: 1em;
            vertical-align: -0.15em;
            fill: currentColor;
            overflow: hidden;
        }

        .myOverflow {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            width: 100%;
            margin-top: 5px;
        }
    </style>
</head>
<body>

<div class="tpanel">
    <div class="panel-content">
        <div class="container-fluid">
            <div id="tool">
                <form id="searchForm" class="form-inline" onsubmit="return search('#searchForm','#table')" style="margin-top:20px;margin-bottom:20px;">
                    <div class="form-group">
                        <label class="">标题：</label>
                        <input type="text" name="search_LIKES_title" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary radius">
                            <span class="glyphicon glyphicon-search"></span> 查询
                        </button>
                        <a class="btn btn-success radius" href="${ctx}/admin/cms/article/create">
                            <span class="glyphicon glyphicon-cog"></span> 创建
                        </a>
                    </div>
                </form>
            </div>
            <table id="table"></table>
        </div>
    </div>
</div>

<script type="text/javascript">
    changeTitle('文章');

    $(function () {
        $('#table').bootstrapTable({
            url: '${ctx}/admin/cms/article/page-list',
            idField: 'id',
            striped: true,
            pagination: true,
            pageNumber: 1,
            pageSize: 25,
            sidePagination: 'server',
            uniqueId: 'id',
            /*checkbox : true,
            clickToSelect : true,*/
            queryParams: queryParams,
            responseHandler: responseHandler,
            columns: [/*{
                field: 'ck',
                checkbox : true
            },*/
                {
                    title: '#',
                    width: 50,
                    align: 'center',
                    formatter: snFormatter
                },
                {
                    title: '标题',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<div class="myOverflow" title="' + row.title + '">' + row.title + '</div>';
                    }
                },
                {
                    title: '摘要',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<div class="myOverflow" title="' + row.summary + '">' + row.summary + '</div>';
                    }
                },
                {
                    title: '作者',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<div class="myOverflow" title="' + row.author + '">' + row.author + '</div>';
                    }
                },
                {
                    field: 'op',
                    title: '操作',
                    align: 'center',
                    formatter: operateFormatter
                }]
        });

    });

    function operateFormatter(value, row, index) {
        var content = '<a href="javascript:comment(' + row.id + ')" title="查看评论"><svg class="icon" aria-hidden="true"><use xlink:href="#icon-pinglun2"></use></svg></a>';
        content += '&nbsp;&nbsp;&nbsp;&nbsp;';
        content += '<a title="查看详情" href="javascript:detail(' + row.id + ')"><i class="iconfont icon-caidanguanli"></i></a>';
        content += '&nbsp;&nbsp;&nbsp;&nbsp;';
        content += '<a href="${ctx}/admin/cms/article/update?id=' + row.id + '" title="编辑"><i class="iconfont icon-iconfontcolor32"></i></a>';
        content += '&nbsp;&nbsp;&nbsp;&nbsp;';
        content += '<a href="javascript:del(' + row.id + ')" title="删除"><i class="iconfont icon-shanchu"></i></a>';
        return content;
    }

    function comment(id) {
        openWindow('查看评论', '${ctx}/admin/cms/tcmsarticlecomment/');
    }

    function detail(id) {
        openWindow('查看详情','${ctx}/admin/cms/article/detail?id=' + id);
    }
    
    function del(id,name) {
        carefulDelete('${ctx}/admin/cms/article/careful-delete',id,'请输入您的管理密码以确定删除此系统资源');
    }
</script>

</body>
</html>
